<template>
  <div class="projectInfo">
    <el-tabs :tab-position="tabPosition" style="height: 200px;" @tab-click="handleClick">
      <el-tab-pane label="项目概况">
        <div class="proInfo">
          <el-form
            :model="ruleForm"
            ref="ruleForm"
            :rules="box1Rules"
            label-width="100px"
            class="demo-ruleForm"
          >
            <div class="proFromLeft">
              <el-form-item label="项目名称" prop="name">
                <el-input v-model.number="ruleForm.name" placeholder="请输入项目名称" :disabled="disTrue"></el-input>
              </el-form-item>

              <el-form-item label="发起人" prop="userId">
                <el-input v-model="ruleForm.userId" placeholder="请输入发起人" disabled></el-input>
              </el-form-item>

              <el-form-item label="货币名称" prop="moneyName">
                <el-input v-model="ruleForm.moneyName" placeholder="请输入货币名称" :disabled="disTrue"></el-input>
              </el-form-item>

              <el-form-item label="预热阶段" prop="preheatStartTime">
                <el-date-picker
                  v-model="ruleForm.preheatStartTime"
                  type="datetime"
                  placeholder="开始时间"
                  style="width:100%"
                  :disabled="disTrue"
                ></el-date-picker>
              </el-form-item>

              <el-form-item label prop="preheatEndTime">
                <el-date-picker
                  v-model="ruleForm.preheatEndTime"
                  type="datetime"
                  placeholder="结束时间"
                  style="width:100%"
                  :disabled="disTrue"
                ></el-date-picker>
              </el-form-item>

              <el-form-item label="配图" prop="illustration">
                <el-upload
                  list-type="picture-card"
                  action="http://mov.freebd.cn:808/img/upload"
                  :file-list="fileList1"
                  :on-success="onSuccess1"
                  :on-remove="onRemove1"
                  :limit="1"
                >
                  <i class="el-icon-plus"></i>
                </el-upload>
              </el-form-item>
            </div>

            <div class="proFromRight">
              <el-form-item label="标签" prop="label1">
                <el-input v-model="ruleForm.label1" placeholder="请输入标签1"></el-input>
              </el-form-item>

              <el-form-item label prop="label2">
                <el-input prop="label2" v-model="ruleForm.label2" placeholder="请输入标签2"></el-input>
              </el-form-item>

              <el-form-item label prop="label3">
                <el-input prop="label3" v-model="ruleForm.label3" placeholder="请输入标签3"></el-input>
              </el-form-item>

              <el-form-item label="项目简介" prop="intro">
                <el-input
                  v-model.number="ruleForm.intro"
                  type="textarea"
                  :rows="5"
                  placeholder="请输入项目简介"
                ></el-input>
              </el-form-item>

              <el-form-item label="回报" prop="repayText">
                <el-input
                  type="textarea"
                  :rows="5"
                  placeholder="请输入回报"
                  v-model="ruleForm.repayText"
                ></el-input>
              </el-form-item>
            </div>

            <div class="proBtn Box1Btn" @click="Box1Edit('ruleForm')">编辑</div>
          </el-form>
        </div>
      </el-tab-pane>

      <el-tab-pane label="募集周期">
        <el-table :data="Box2List" border style="width: 100%">
          <el-table-column prop="index" label="序号" width="120"></el-table-column>
          <el-table-column prop="title" label="募集阶段"></el-table-column>
          <el-table-column prop="sum" label="募集总额"></el-table-column>
          <el-table-column prop="unitPrice" label="发行单价(MOV)"></el-table-column>
          <el-table-column prop="quantityCompleted" label="已募集"></el-table-column>
          <el-table-column prop="startTime" label="开始时间"></el-table-column>
          <el-table-column prop="endTime" label="结束时间"></el-table-column>
          <!-- 0:未开始 1:进行中 2:已完成  -->
          <el-table-column label="状态">
            <template slot-scope="scope">
              <el-button type="text" v-show="scope.row.type == 1 && scope.row.current == 2">未开始</el-button>
              <el-button type="text" v-show="scope.row.type == 1 && scope.row.current == 1">进行中</el-button>
              <el-button type="text" v-show="scope.row.type == 0">已完成</el-button>
              <el-button type="text" v-show="scope.row.type == 1 && scope.row.current == 0">失败</el-button>
            </template>
          </el-table-column>
          <el-table-column prop="ratio" label="进度"></el-table-column>
          <el-table-column label="操作">
            <template slot-scope="scope">
              <el-button type="text" @click="Box2EditClick(scope.row)" v-show="!disTrue">编辑</el-button>
              <el-button type="text" @click="Box2DelClick(scope.row)" v-show="!disTrue">删除</el-button>
            </template>
          </el-table-column>
        </el-table>
        <div style="margin-top:20px" v-show="!disTrue">
          <div class="proBtn" @click="Box2AddClick()">新增</div>
        </div>
      </el-tab-pane>

      <el-tab-pane label="基本信息">
        <div class="InfoMation">
          <quillEditor v-model.trim="text"></quillEditor>
        </div>
        <div class="proBtn" style="margin-top:20px" @click="box3Click()">保存</div>
      </el-tab-pane>

      <el-tab-pane label="项目动态">
        <div style="margin:20px 0">
          <el-button type="primary" @click="box4Add()">新增</el-button>
          <el-button type="primary" @click.stop="box4Click()">提交</el-button>
        </div>
        <el-table :data="Box4List" border style="width: 100%">
          <el-table-column prop="index" label="序号" width="120"></el-table-column>
          <el-table-column label="标题">
            <template slot-scope="scope">
              <el-input v-model="scope.row.title" placeholder="请输入内容"></el-input>
            </template>
          </el-table-column>
          <el-table-column prop="name" label="说明" width="500">
            <template slot-scope="scope">
              <el-input v-model="scope.row.content" type="textarea" placeholder="请输入内容"></el-input>
            </template>
          </el-table-column>
          <el-table-column prop="startTime" label="开始时间">
            <template slot-scope="scope">
              <el-date-picker
                v-model="scope.row.startTime"
                type="datetime"
                placeholder="开始时间"
                style="width: 100%"
              ></el-date-picker>
            </template>
          </el-table-column>
          <el-table-column label="操作" width="80">
            <template slot-scope="scope">
              <!-- <el-button type="text" @click="box4Edit(scope.row)">编辑</el-button> -->
              <el-button type="text" @click="box4Delete(scope.row)">删除</el-button>
            </template>
          </el-table-column>
        </el-table>
      </el-tab-pane>

      <el-tab-pane label="媒体报道">
        <el-table :data="box5List" border style="width: 100%">
          <el-table-column prop="index" label="序号" width="120"></el-table-column>
          <el-table-column prop="title" label="标题"></el-table-column>
          <el-table-column label="内容简介">
            <template slot-scope="scope">
              <div v-html="scope.row.content" class="media-quill"></div>
            </template>
          </el-table-column>
          <el-table-column prop="createTime" label="创建时间"></el-table-column>
          <el-table-column label="操作">
            <template slot-scope="scope">
              <el-button type="text" @click="box5Edit(scope.row)">编辑</el-button>
              <el-button type="text" @click="box5Delete(scope.row)">删除</el-button>
            </template>
          </el-table-column>
        </el-table>
        <div class="proBtn" style="margin-top:20px" @click="box5Add()">新增</div>
      </el-tab-pane>

      <el-tab-pane label="自定义">
        <el-table :data="box6List" border style="width: 100%">
          <el-table-column prop="index" label="序号" width="120"></el-table-column>
          <el-table-column prop="title" label="标题"></el-table-column>
          <el-table-column prop="content" label="内容简介"></el-table-column>
          <el-table-column prop="createTime" label="创建时间"></el-table-column>
          <el-table-column label="操作">
            <template slot-scope="scope">
              <el-button type="text" @click="box6Edit(scope.row)">编辑</el-button>
              <el-button type="text" @click="box6Delete(scope.row)">删除</el-button>
            </template>
          </el-table-column>
        </el-table>
        <div class="proBtn" style="margin-top:20px" @click="box6Add()">新增</div>
      </el-tab-pane>

      <el-tab-pane label="支持者">
        <el-table :data="box7List" border style="width: 100%">
          <el-table-column prop="index" label="序号" width="120"></el-table-column>
          <el-table-column prop="nikename" label="姓名"></el-table-column>
          <!-- <el-table-column prop="sum" label="手机号"></el-table-column> -->
          <el-table-column prop="sum" label="支持总额"></el-table-column>
          <el-table-column prop="createTime" label="时间"></el-table-column>
        </el-table>
      </el-tab-pane>
      <el-tab-pane label="评论">
        <el-table :data="box8List" border style="width: 100%">
          <el-table-column prop="index" label="序号" width="120"></el-table-column>
          <el-table-column prop="nikeName" label="姓名"></el-table-column>
          <el-table-column prop="phone" label="手机号"></el-table-column>
          <el-table-column prop="content" label="评论内容"></el-table-column>
          <el-table-column prop="createTime" label="时间"></el-table-column>
          <el-table-column label="操作">
            <template slot-scope="scope">
              <!-- <el-button type="text" @click="handleInfo(scope.row)">详情</el-button> -->
              <el-button type="text" @click="box8Delete(scope.row)">删除</el-button>
            </template>
          </el-table-column>
        </el-table>
      </el-tab-pane>

      <el-tab-pane label="关注">
        <el-table :data="box9List" border style="width: 100%">
          <el-table-column prop="index" label="序号" width="120"></el-table-column>
          <el-table-column prop="nikename" label="姓名"></el-table-column>
          <el-table-column prop="createTime" label="时间"></el-table-column>
          <el-table-column prop="phone" label="手机号"></el-table-column>
        </el-table>
      </el-tab-pane>

      <el-tab-pane label="导入票房">
        <el-table :data="box10List" border style="width: 100%">
          <el-table-column prop="index" label="序号" width="120"></el-table-column>
          <el-table-column prop="source" label="票房来源"></el-table-column>
          <el-table-column prop="money" label="票房收入(元)"></el-table-column>
          <el-table-column label="操作">
            <template slot-scope="scope">
              <el-button type="text" @click="box10EditClick(scope.row)">编辑</el-button>
            </template>
          </el-table-column>
        </el-table>
        <div style="margin-top:20px">累计票房: {{this.AllPrice}}</div>
        <div class="proBtn" style="margin-top:20px" @click="box10AddClick()">新增</div>
        <div class="proBtn" style="margin-top:20px" @click="box10PullBonus()">生成分红数据</div>
      </el-tab-pane>
    </el-tabs>
    <!-- box5 媒体报道-->
    <el-dialog title="媒体报道" @close="Cancel" :visible.sync="dialogBox5Add" width="30%">
      <!-- :rules="rules" -->
      <el-form
        :model="ruleFormBox5"
        ref="ruleFormBox5"
        :rules="box5Rules"
        label-width="100px"
        class="demo-ruleForm"
      >
        <el-form-item label="标题" prop="title">
          <el-input v-model="ruleFormBox5.title" placeholder="请输入标题"></el-input>
        </el-form-item>

        <el-form-item label="内容" prop="content">
          <quillEditor v-model.trim="ruleFormBox5.content"></quillEditor>
          <!-- <el-input v-model="ruleFormBox5.content" type="textarea" :rows="5" placeholder="请输入内容"></el-input> -->
        </el-form-item>
        <div style="text-align:right;">
          <el-button @click="Cancel">取 消</el-button>
          <el-button type="primary" @click="Box5Click('ruleFormBox5')">确 定</el-button>
        </div>
      </el-form>
    </el-dialog>

    <!-- box6 自定义-->
    <el-dialog title="自定义" @close="Cancel" :visible.sync="dialogBox6Add" width="30%">
      <!-- :rules="rules" -->
      <el-form
        :model="ruleFormBox6"
        ref="ruleFormBox6"
        :rules="box6Rules"
        label-width="100px"
        class="demo-ruleForm"
      >
        <el-form-item label="标题" prop="title">
          <el-input v-model="ruleFormBox6.title" placeholder="请输入标题"></el-input>
        </el-form-item>

        <el-form-item label="内容" prop="content">
          <el-input v-model="ruleFormBox6.content" type="textarea" :rows="5" placeholder="请输入内容"></el-input>
        </el-form-item>
        <div style="text-align:right;">
          <el-button @click="Cancel">取 消</el-button>
          <el-button type="primary" @click="Box6Click('ruleFormBox6')">确 定</el-button>
        </div>
      </el-form>
    </el-dialog>

    <!-- box2募集周期新增编辑 -->
    <el-dialog title="募集周期" @close="Cancel" :visible.sync="dialogBox2Add" width="30%">
      <!-- :rules="rules" -->
      <el-form
        :model="ruleFormBox2"
        ref="ruleFormBox2"
        :rules="rules2"
        label-width="110px"
        class="demo-ruleForm"
      >
        <el-form-item label="开始时间" prop="startTime">
          <el-date-picker
            v-model="ruleFormBox2.startTime"
            type="datetime"
            placeholder="开始时间"
            style="width: 100%;"
          ></el-date-picker>
        </el-form-item>

        <el-form-item label="结束时间" prop="endTime">
          <el-date-picker
            v-model="ruleFormBox2.endTime"
            type="datetime"
            placeholder="结束时间"
            style="width: 100%;"
          ></el-date-picker>
        </el-form-item>

        <el-form-item label="募集阶段标题" prop="title">
          <el-input v-model="ruleFormBox2.title" placeholder="请输入募集阶段的标题"></el-input>
        </el-form-item>

        <el-form-item label="发行单价" prop="unitPrice">
          <!-- @blur="onBlur()" -->
          <el-input v-model.number="ruleFormBox2.unitPrice" placeholder="请输入发行单价" @blur="onBlur()"></el-input>
          <span class="MOV">MOV</span>
        </el-form-item>

        <el-form-item label="货币数量" prop="surplusNumber">
          <el-input
            v-model.number="ruleFormBox2.surplusNumber"
            placeholder="请输入货币数量"
            @blur="onBlur()"
          ></el-input>
        </el-form-item>

        <el-form-item label="募集总额" prop="sum">
          <el-input v-model.number="ruleFormBox2.sum" disabled></el-input>
        </el-form-item>

        <div style="text-align:right;">
          <el-button @click="Cancel">取 消</el-button>
          <el-button type="primary" @click="Box2Click('ruleFormBox2')">确 定</el-button>
        </div>
      </el-form>
    </el-dialog>

    <!-- box10导入票房 -->
    <el-dialog title="导入票房" @close="Cancel" :visible.sync="dialogBox10Add" width="30%">
      <!-- :rules="rules" -->
      <el-form
        :model="ruleFormBox10"
        ref="ruleFormBox10"
        :rules="box10Rules"
        label-width="100px"
        class="demo-ruleForm"
      >
        <el-form-item label="票房来源" prop="source">
          <el-input v-model="ruleFormBox10.source" placeholder="请输入发行代币名称"></el-input>
        </el-form-item>

        <el-form-item label="票房收入" prop="money">
          <el-input v-model.number="ruleFormBox10.money" placeholder="请输入募集总额"></el-input>
        </el-form-item>
        <div style="text-align:right;">
          <el-button @click="Cancel">取 消</el-button>
          <el-button type="primary" @click="Box10Click('ruleFormBox10')">确 定</el-button>
        </div>
      </el-form>
    </el-dialog>
  </div>
</template>
<script>
import moment from "moment";

import { quillEditor } from "vue-quill-editor";

import "quill/dist/quill.core.css";
import "quill/dist/quill.snow.css";
import "quill/dist/quill.bubble.css";
export default {
  data() {
    return {
      val: 1,
      id: 0,
      type: 0,
      tabPosition: "left",
      //box1
      disTrue: false,
      fileList1: [],
      ruleForm: {
        name: "",
        moneyName: "",
        userId: "武汉九恒影业有限公司",
        label1: "",
        label2: "",
        label3: "",
        intro: "",
        repayText: "",
        preheatStartTime: "",
        preheatEndTime: "",
        illustration: ""
      },
      box1Rules: {
        name: [
          { required: true, message: "请输入项目", trigger: "blur" },
          { max: 20, message: "输入内容过长", trigger: "blur" }
        ],
        moneyName: [
          { required: true, message: "请输入发行代币名称", trigger: "blur" },
          { max: 10, message: "输入内容过长", trigger: "blur" }
        ],
        label1: [
          { required: true, message: "请输入标签1", trigger: "blur" },
          {
            min: 1,
            max: 6,
            message: "标签长度在 1 到 6 个字符之间",
            trigger: "blur"
          }
        ],
        label2: [
          { required: true, message: "请输入标签2", trigger: "blur" },
          {
            min: 1,
            max: 6,
            message: "标签长度在 1 到 6 个字符之间",
            trigger: "blur"
          }
        ],
        label3: [
          { required: true, message: "请输入标签3", trigger: "blur" },
          {
            min: 1,
            max: 6,
            message: "标签长度在 1 到 6 个字符之间",
            trigger: "blur"
          }
        ],
        intro: [
          { required: true, message: "请输入项目简介", trigger: "blur" },
          { max: 500, message: "请输入500字以内简介", trigger: "blur" }
        ],
        repayText: [
          { max: 200, message: "请输入200字以内回报", trigger: "blur" }
        ],
        preheatStartTime: [
          { required: true, message: "请输入预热阶段", trigger: "blur" }
        ],
        preheatEndTime: [
          { required: true, message: "请输入预热阶段", trigger: "blur" }
        ],
        illustration: [
          { required: true, message: "请上传配图", trigger: "blur" }
        ]
      },
      //box2
      dialogBox2Add: false,
      box2Flag: 1,
      box2EditId: "",
      Box2List: [],
      ruleFormBox2: {
        projectsId: "", //项目id ,
        startTime: "", //开始时间 ,
        endTime: "", // 结束时间 ,
        sum: "", // 募集总额 ,
        surplusNumber: "", //货币数量 ,
        title: "", //募集阶段的标题 ,
        unitPrice: "" // 发行单价
      },
      rules2: {
        startTime: [
          { required: true, message: "请输入开始时间", trigger: "blur" }
        ],
        endTime: [
          { required: true, message: "请输入结束时间", trigger: "blur" }
        ],
        surplusNumber: [
          { required: true, message: "请输入货币数量", trigger: "blur" },
          { type: "number", message: "请输入数字", trigger: "blur" }
        ],
        title: [
          { required: true, message: "请输入募集阶段的标题", trigger: "blur" }
        ],
        unitPrice: [
          { required: true, message: "请输入发行单价", trigger: "blur" },
          { type: "number", message: "请输入数字", trigger: "blur" }
        ]
      },
      //box3
      text: "",
      List: [],
      //box4
      Box4List: [],
      flagTrim: "",
      timeArr: [],
      //box5
      box5List: [],
      dialogBox5Add: false,
      ruleFormBox5: {
        title: "",
        content: ""
      },
      box5Flag: 1,
      box5EditId: "",
      box5Rules: {
        title: [
          { required: true, message: "请输入标题", trigger: "blur" },
          { max: 20, message: "输入标题过长", trigger: "blur" }
        ],
        content: [
          { required: true, message: "请输入内容", trigger: "blur" }
          // { max: 500, message: "请输入500字以内内容", trigger: "blur" }
        ]
      },
      //box6
      box6List: [],
      dialogBox6Add: false,
      ruleFormBox6: {
        title: "",
        content: ""
      },
      box6Flag: 1,
      box6EditId: "",
      box6Rules: {
        title: [
          { required: true, message: "请输入标题", trigger: "blur" },
          { max: 20, message: "输入标题过长", trigger: "blur" }
        ],
        content: [
          { required: true, message: "请输入内容", trigger: "blur" },
          { max: 500, message: "请输入500字以内内容", trigger: "blur" }
        ]
      },
      //box7
      box7List: [],
      //box8
      box8List: [],
      //box9
      box9List: [],
      //box10
      AllPrice: 0,
      box10List: [],
      box10EditId: "",
      box10Flag: "",
      dialogBox10Add: false,
      ruleFormBox10: {
        money: "",
        source: ""
      },
      box10Rules: {
        money: [
          { required: true, message: "请输入票房收入", trigger: "blur" },
          { type: "number", message: "请输入数字", trigger: "blur" }
        ],
        source: [{ required: true, message: "请输入票房来源", trigger: "blur" }]
      }
    };
  },
  components: {
    quillEditor
  },
  created() {
    this.id = this.$route.query.id;
    this.type = this.$route.query.type;
    //Box1禁用
    if (this.type == 2 || this.type == 3 || this.type == 4) {
      this.disTrue = true;
    }
    this.getBox1List();
  },
  methods: {
    handleClick(tab, event) {
      if (tab.index == 0) {
        this.getBox1List();
      } else if (tab.index == 1) {
        this.getBox2List();
      } else if (tab.index == 2) {
        this.box3getInfo();
      } else if (tab.index == 3) {
        this.getBox4List();
      } else if (tab.index == 4) {
        this.getBox5List();
      } else if (tab.index == 5) {
        this.getBox6List();
      } else if (tab.index == 6) {
        this.getBox7List();
      } else if (tab.index == 7) {
        this.getBox8List();
      } else if (tab.index == 8) {
        this.getBox9List();
      } else {
        this.getBox10List();
      }
    },
    //图片上传
    onSuccess1(Response, file, fileList) {
      this.ruleForm.illustration = file.response.data.path;
    },
    //删除
    onRemove1(file, fileList) {
      this.ruleForm.illustration = "";
      this.fileList1 = [];
    },
    //box1
    //根据id获取数据
    getBox1List() {
      let url = "/projects/get/" + this.id;
      this.httpPost(url, {}, res => {
        if (res.code == 200) {
          // this.Box1Info = res.data;
          this.ruleForm.name = res.data.name;
          this.ruleForm.moneyName = res.data.moneyName;
          // this.ruleForm.userId = res.data.userId;
          let lable = res.data.label;
          this.ruleForm.label1 = lable.split(",")[0];
          this.ruleForm.label2 = lable.split(",")[1];
          this.ruleForm.label3 = lable.split(",")[2];
          this.ruleForm.intro = res.data.intro;
          this.ruleForm.repayText = res.data.repayText;
          this.ruleForm.preheatStartTime = res.data.preheatStartTime;
          this.ruleForm.preheatEndTime = res.data.preheatEndTime;
          this.ruleForm.illustration = res.data.illustration;
          if (this.ruleForm.illustration && this.fileList1.length == 0) {
            this.fileList1.push({
              url: "http://mov.freebd.cn:808/file" + this.ruleForm.illustration
            });
          }
          //富文本
          this.text = res.data.descInfo;
        }
      });
    },
    //编辑
    Box1Edit(formName) {
      this.$refs[formName].validate(valid => {
        if (valid) {
          this.ruleForm.preheatStartTime = moment(
            this.ruleForm.preheatStartTime,
            "YYYY-MM-DD HH:mm:ss"
          ).valueOf();
          this.ruleForm.preheatEndTime = moment(
            this.ruleForm.preheatEndTime,
            "YYYY-MM-DD HH:mm:ss"
          ).valueOf();

          if (this.ruleForm.preheatStartTime > this.ruleForm.preheatEndTime) {
            this.$message({
              message: "开始时间不可大于结束时间",
              type: "success"
            });
            return;
          } else {
            let url = "/projects/edit";
            let params = {
              id: this.id,
              intro: this.ruleForm.intro, //项目简介 ,
              label:
                this.ruleForm.label1 +
                "," +
                this.ruleForm.label2 +
                "," +
                this.ruleForm.label3, //标签（3个）(逗号分隔) ,
              moneyName: this.ruleForm.moneyName, //发行代币名称 ,
              name: this.ruleForm.name, //项目名称 ,
              preheatEndTime: this.ruleForm.preheatEndTime, //预热 结束时间 ,
              preheatStartTime: this.ruleForm.preheatStartTime, //预热 开始时间 ,
              repayText: this.ruleForm.repayText, //回报文本 ,
              userId: 1, // 用户ID,
              illustration: this.ruleForm.illustration
            };
            console.log(params);
            this.httpPost(url, params, res => {
              if (res.code == 200) {
                this.$message({
                  message: "编辑成功",
                  type: "success"
                });
              }
            });
          }
        }
      });
    },

    //box2根据id查询数据
    getBox2List(id) {
      let url = "/raises/getList/" + this.id;
      this.httpGet(url, res => {
        if (res.code == 200) {
          this.Box2List = res.data;
          this.Box2List.forEach((element, i) => {
            this.Box2List[i].index = (this.val - 1) * 10 + i + 1;
          });
        } else {
          console.log("查询失败");
        }
      });
    },
    //新增
    Box2AddClick() {
      this.dialogBox2Add = true;
      this.box2Flag = 1;
    },
    //删除
    Box2DelClick(row) {
      this.$confirm("是否删除此数据？", "删除", {
        distinguishCancelAndClose: true,
        confirmButtonText: "删除",
        cancelButtonText: "取消"
      })
        .then(() => {
          let url = "/raises/edit";
          let params = {
            projectsId: this.id,
            id: row.id,
            status: 1
          };
          this.httpPost(url, params, res => {
            if (res.code == 200) {
              this.$message({
                message: "删除成功",
                type: "success"
              });
              this.getBox2List();
            } else {
              this.$message({
                message: res.message,
                type: "warning"
              });
            }
          });
        })
        .catch(action => {
          this.$message({
            type: "info",
            message: "取消删除"
          });
        });
    },
    //编辑
    Box2EditClick(row) {
      this.dialogBox2Add = true;
      this.box2Flag = 2;
      this.box2EditId = row.id;
      (this.ruleFormBox2.startTime = row.startTime), //开始时间 ,
        (this.ruleFormBox2.endTime = row.endTime), // 结束时间 ,
        (this.ruleFormBox2.sum = row.sum), // 募集总额 ,
        (this.ruleFormBox2.surplusNumber = row.surplusNumber), //货币数量 ,
        (this.ruleFormBox2.title = row.title), //募集阶段的标题 ,
        (this.ruleFormBox2.unitPrice = row.unitPrice); // 发行单价
    },
    onBlur() {
      console.log("失去焦点");
      console.log(this.ruleFormBox2.unitPrice);
      console.log(this.ruleFormBox2.surplusNumber);

      if (
        this.ruleFormBox2.unitPrice !== "" &&
        this.ruleFormBox2.surplusNumber != ""
      ) {
        this.ruleFormBox2.sum =
          this.ruleFormBox2.unitPrice * this.ruleFormBox2.surplusNumber;
      }
    },
    //确定
    Box2Click(formName) {
      // sum  募集总额计算
      this.$refs[formName].validate(valid => {
        if (valid) {
          this.ruleFormBox2.startTime = moment(
            this.ruleFormBox2.startTime,
            "YYYY-MM-DD HH:mm:ss"
          ).valueOf();
          this.ruleFormBox2.endTime = moment(
            this.ruleFormBox2.endTime,
            "YYYY-MM-DD HH:mm:ss"
          ).valueOf();
          if (this.box2Flag == 1) {
            let url = "/raises/add";
            let params = {
              projectsId: this.id,
              startTime: this.ruleFormBox2.startTime, //开始时间 ,
              endTime: this.ruleFormBox2.endTime, // 结束时间 ,
              sum: this.ruleFormBox2.sum, // 募集总额 ,
              surplusNumber: this.ruleFormBox2.surplusNumber, //货币数量 ,
              title: this.ruleFormBox2.title, //募集阶段的标题 ,
              unitPrice: this.ruleFormBox2.unitPrice // 发行单价
            };
            this.httpPost(url, params, res => {
              if (res.code == 200) {
                this.$message({
                  message: "新增成功",
                  type: "success"
                });
                this.dialogBox2Add = false;
                this.getBox2List();
                this.ruleFormBox2 = {};
              } else if (res.code == 605) {
                this.$message({
                  message: "请先发行代币",
                  type: "warning"
                });
                setTimeout(() => {
                  // this.$route.push("/projectList");
                  this.$router.push("/projectList");
                }, 1500);
              } else {
                this.$message({
                  message: res.message,
                  type: "warning"
                });
              }
            });
          } else {
            let url = "/raises/edit";
            let params = {
              id: this.box2EditId,
              projectsId: this.id,
              startTime: this.ruleFormBox2.startTime, //开始时间 ,
              endTime: this.ruleFormBox2.endTime, // 结束时间 ,
              sum: this.ruleFormBox2.sum, // 募集总额 ,
              surplusNumber: this.ruleFormBox2.surplusNumber, //货币数量 ,
              title: this.ruleFormBox2.title, //募集阶段的标题 ,
              unitPrice: this.ruleFormBox2.unitPrice // 发行单价
            };
            this.httpPost(url, params, res => {
              if (res.code == 200) {
                this.$message({
                  message: "编辑成功",
                  type: "success"
                });
                this.dialogBox2Add = false;
                this.getBox2List();
              } else {
                this.$message({
                  message: res.message,
                  type: "warning"
                });
              }
            });
          }
        }
      });
    },
    //取消
    Cancel() {
      this.dialogBox2Add = false;
      this.ruleFormBox2 = {};
      this.dialogBox4Add = false;
      this.ruleFormBox2 = {};
      this.dialogBox5Add = false;
      this.ruleFormBox5 = {};
      this.dialogBox6Add = false;
      this.ruleFormBox6 = {};
      this.dialogBox10Add = false;
      this.ruleFormBox10 = {};
    },

    //box3
    box3Click() {
      if (this.text == "") {
        this.$message({
          message: "请输入基本信息",
          type: "warning"
        });
      } else {
        let url = "/projects/edit";
        let params = {
          id: this.id,
          descInfo: this.text
        };
        this.httpPost(url, params, res => {
          if (res.code == 200) {
            this.$message({
              message: "编辑成功",
              type: "success"
            });
          }
        });
      }
    },
    box3getInfo() {
      let url = "/information/get";
      let params = {
        projectsId: this.id
      };
      this.httpPost(url, params, res => {
        if (res.code == 200) {
          // this.text = ""
        }
      });
    },

    //box4
    getBox4List() {
      // Box4List
      let url = "/information/getList";
      let params = {
        pageNum: this.val,
        pageSize: 10,
        projectsId: this.id,
        type: 0
      };
      this.httpPost(url, params, res => {
        if (res.code == 200) {
          this.Box4List = res.data.list;
          this.Box4List.forEach((element, i) => {
            this.Box4List[i].index = (this.val - 1) * 10 + i + 1;
          });
        }
      });
    },
    //新增
    box4Add() {
      this.Box4List.push({ index: "", title: "", content: "", startTime: "" });
    },
    box4Click() {
      this.Box4List.forEach((element, i) => {
        // if (
        //   element.title == "" ||
        //   element.content == "" ||
        //   element.startTime == null
        // ) {
        //   this.flagTrim = 0;
        //   this.$message({
        //     message: "提交失败，请将信息填写完整",
        //     type: "warning"
        //   });
          // this.getBox4List();
          // return;
        // } else {
          element.startTime = Date.parse(element.startTime);
          // this.flagTrim = 1;
        // }
        // console.log(this.flagTrim, "失败");
      });
          //   this.timeArr.push(element.startTime);
          //   this.timeArr.forEach((element, i) => {
          //     if (i < this.timeArr.length - 1) {
          //       if (this.timeArr[i].startTime > this.timeArr[i + 1].startTime) {
          //         this.$message({
          //           message: "时间排序不对",
          //           type: "warning"
          //         });
          // this.flagTrim = 0;
          //         this.getBox4List();
          //         return;
          //       }
          //       console.log(this.timeArr[i].startTime );
          //     }
          //   });
      // console.log(this.flagTrim === 0);

      // if (this.flagTrim) {
        let url = "/information/add";
        let params = {
          id: this.id,
          list: this.Box4List
        };
        this.httpPost(url, params, res => {
          if (res.code == 200) {
            this.$message({
              message: "提交成功",
              type: "success"
            });
            this.getBox4List();
          } else {
            this.$message({
              message: res.message,
              type: "warning"
            });
          }
        });
      // }
    },

    //删除
    box4Delete(row) {
      this.$confirm("此操作将永久删除该文件, 是否继续?", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning"
      })
        .then(() => {
          this.Box4List.splice(row.index - 1, 1);
          let url = "/information/add"; //delete
          let params = {
            id: this.id,
            list: this.Box4List
          };
          this.httpPost(url, params, res => {
            if (res.code == 200) {
              this.$message({
                message: "删除成功",
                type: "success"
              });
              this.getBox4List();
            }
          });
        })
        .catch(() => {
          this.$message({
            type: "info",
            message: "已取消删除"
          });
        });
    },
    //box5  媒体报道
    getBox5List() {
      let url = "/information/getList";
      let params = {
        pageNum: this.val,
        pageSize: 10,
        type: 1,
        projectsId: this.id
      };
      this.httpPost(url, params, res => {
        if (res.code == 200) {
          this.box5List = res.data.list;
          console.log(this.Box4List);
          this.box5List.forEach((element, i) => {
            this.box5List[i].index = (this.val - 1) * 10 + i + 1;
          });
        }
      });
    },
    box5Add() {
      this.box5Flag = 1;
      this.dialogBox5Add = true;
      this.ruleFormBox5.title = "";
      this.ruleFormBox5.content = "";
    },
    box5Edit(row) {
      this.box5Flag = 2;
      this.dialogBox5Add = true;
      this.box5EditId = row.id;
      this.ruleFormBox5.title = row.title;
      this.ruleFormBox5.content = row.content;
    },
    box5Delete(row) {
      let url = "/information/editOne";
      let params = {
        id: row.id,
        status: 1
      };
      this.httpPost(url, params, res => {
        if (res.code == 200) {
          this.$message({
            message: "删除成功",
            type: "success"
          });
        }
        this.getBox5List();
      });
    },
    Box5Click(formName) {
      this.$refs[formName].validate(valid => {
        if (valid) {
          if (this.box5Flag == 1) {
            let url = "/information/addOne";
            let params = {
              content: this.ruleFormBox5.content,
              title: this.ruleFormBox5.title,
              type: 1,
              projectsId: this.id
            };
            this.httpPost(url, params, res => {
              if (res.code == 200) {
                this.$message({
                  message: "新增成功",
                  type: "success"
                });
                this.dialogBox5Add = false;
                this.ruleFormBox5 = {};
                this.getBox5List();
              } else {
                this.$message({
                  message: res.message,
                  type: "warning"
                });
              }
            });
          } else {
            let url = "/information/editOne";
            let params = {
              content: this.ruleFormBox5.content,
              title: this.ruleFormBox5.title,
              type: 1,
              projectsId: this.id,
              id: this.box5EditId
            };
            this.httpPost(url, params, res => {
              if (res.code == 200) {
                this.$message({
                  message: "新增成功",
                  type: "success"
                });
              }
              this.dialogBox5Add = false;
              this.getBox5List();
            });
          }
        }
      });
    },

    //box6  自定义
    getBox6List() {
      let url = "/information/getList";
      let params = {
        pageNum: this.val,
        pageSize: 10,
        type: 2,
        projectsId: this.id
      };
      this.httpPost(url, params, res => {
        if (res.code == 200) {
          this.box6List = res.data.list;
          console.log(this.box6List);
          this.box6List.forEach((element, i) => {
            this.box6List[i].index = (this.val - 1) * 10 + i + 1;
          });
        }
      });
    },
    box6Add() {
      this.box6Flag = 1;
      this.dialogBox6Add = true;
      this.ruleFormBox6.title = "";
      this.ruleFormBox6.content = "";
    },
    box6Edit(row) {
      this.box6Flag = 2;
      this.dialogBox6Add = true;
      this.box6EditId = row.id;
      this.ruleFormBox6.title = row.title;
      this.ruleFormBox6.content = row.content;
    },
    box6Delete(row) {
      let url = "/information/editOne";
      let params = {
        id: row.id,
        status: 1
      };
      this.httpPost(url, params, res => {
        if (res.code == 200) {
          this.$message({
            message: "删除成功",
            type: "success"
          });
        }
        this.getBox6List();
      });
    },
    Box6Click(formName) {
      if (this.box6Flag == 1) {
        let url = "/information/addOne";
        let params = {
          content: this.ruleFormBox6.content,
          title: this.ruleFormBox6.title,
          type: 2,
          projectsId: this.id
        };
        this.httpPost(url, params, res => {
          if (res.code == 200) {
            this.$message({
              message: "新增成功",
              type: "success"
            });
            this.dialogBox6Add = false;
            this.getBox6List();
            this.ruleFormBox6 = {};
          } else {
            this.$message({
              message: res.message,
              type: "warning"
            });
          }
        });
      } else {
        let url = "/information/editOne";
        let params = {
          content: this.ruleFormBox6.content,
          title: this.ruleFormBox6.title,
          type: 2,
          projectsId: this.id,
          id: this.box6EditId
        };
        this.httpPost(url, params, res => {
          if (res.code == 200) {
            this.$message({
              message: "新增成功",
              type: "success"
            });
            this.dialogBox6Add = false;
            this.getBox6List();
            this.ruleFormBox6 = {};
          } else {
            this.$message({
              message: res.message,
              type: "warning"
            });
          }
        });
      }
    },

    //box7
    //获取列表
    getBox7List() {
      let url = "/stock/projectPurchase/" + this.id;
      this.httpPost(url, {}, res => {
        if (res.code == 200) {
          this.box7List = res.data;
          this.box7List.forEach((element, i) => {
            this.box7List[i].index = (this.val - 1) * 10 + i + 1;
          });
        }
      });
    },

    //box8
    //获取列表
    getBox8List() {
      let url = "/assess/allAssess";
      let params = {
        pageNum: this.val,
        pageSize: 10,
        projectsId: this.id
      };
      this.httpPost(url, params, res => {
        if (res.code == 200) {
          this.box8List = res.data.list;
          this.box8List.forEach((element, i) => {
            this.box8List[i].index = (this.val - 1) * 10 + i + 1;
          });
        }
      });
    },
    //删除
    box8Delete(row) {
      let url = "/assess/deleteAssess?id=" + row.id;
      this.httpPost(url, {}, res => {
        if (res.code == 200) {
          this.$message({
            message: "删除成功",
            type: "success"
          });
          this.getBox8List();
        }
      });
    },
    //查看详情
    // getBox8Info() {
    //   let url = "/assess/get";
    //   let params = {
    //     id: 1
    //   };
    //   this.httpPost(url, params, res => {
    //     if (res.code == 200) {
    //       console.log(res.data);
    //     }
    //   });
    // },

    //Box9
    //获取数据
    getBox9List() {
      let url = "/follow/allFollow";
      let params = {
        pageNum: this.val,
        pageSize: 10,
        projectsId: this.id
      };
      this.httpPost(url, params, res => {
        if (res.code == 200) {
          this.box9List = res.data.list;
          this.box9List.forEach((element, i) => {
            this.box9List[i].index = (this.val - 1) * 10 + i + 1;
          });
        }
      });
    },

    //Box10
    //获取数据
    getBox10List() {
      let url = "/boxOffice/getList";
      let params = {
        pageNum: this.val,
        pageSize: 10,
        projectsId: this.id
      };
      this.httpPost(url, params, res => {
        if (res.code == 200) {
          this.box10List = res.data.list;
          this.box10List.forEach((element, i) => {
            this.box10List[i].index = (this.val - 1) * 10 + i + 1;
            this.AllPrice += this.box10List[i].money;
          });
        }
      });
    },
    //新增和编辑
    box10AddClick() {
      this.box10Flag = 1;
      this.dialogBox10Add = true;
      this.ruleFormBox10.money = "";
      this.ruleFormBox10.source = "";
    },
    box10EditClick(row) {
      this.box10Flag = 2;
      (this.box10EditId = row.id), (this.dialogBox10Add = true);
      this.ruleFormBox10.source = row.source;
      this.ruleFormBox10.money = row.money;
    },
    Box10Click(formName) {
      this.$refs[formName].validate(valid => {
        if (valid) {
          if (this.box10Flag == 1) {
            let url = "/boxOffice/add";
            let params = {
              source: this.ruleFormBox10.source,
              money: this.ruleFormBox10.money,
              projectsId: this.id
            };
            this.httpPost(url, params, res => {
              if (res.code == 200) {
                this.$message({
                  message: "新增成功",
                  type: "success"
                });
                this.dialogBox10Add = false;
                this.AllPrice = 0; //清空
                this.getBox10List();
                this.ruleFormBox10 = {};
              } else {
                this.$message({
                  message: res.message,
                  type: "warning"
                });
              }
            });
          } else {
            let url = "/boxOffice/edit";
            let params = {
              source: this.ruleFormBox10.source,
              money: this.ruleFormBox10.money,
              projectsId: this.id,
              id: this.box10EditId
            };
            this.httpPost(url, params, res => {
              if (res.code == 200) {
                this.$message({
                  message: "编辑成功",
                  type: "success"
                });
                this.dialogBox10Add = false;
                this.AllPrice = 0; //清空
                this.getBox10List();
                this.ruleFormBox10 = {};
              } else {
                this.$message({
                  message: res.message,
                  type: "warning"
                });
              }
            });
          }
        }
      });
    },
    //分红
    box10PullBonus() {
      let url = "/boxOffice/pullBonus";
      let params = {
        projectsId: this.id,
        sum: this.AllPrice
      };
      this.httpPost(url, params, res => {
        if (res.code == 200) {
          this.$message({
            message: "生成分红成功",
            type: "success"
          });
        }
      });
    }
  }
};
</script>

<style lang="scss" scoped>
.proBtn {
  display: inline-block;
  width: 120px;
  height: 40px;
  line-height: 40px;
  text-align: center;
  color: #fff;
  font-size: 16px;
  background: #409eff;
  border-radius: 5px;
}
/* 项目概况 */
.proInfo {
  width: 70%;
  height: 530px;
  position: relative;
  .proFromLeft {
    float: left;
    // background: pink;
    width: 450px;
    height: 100%;
  }
  .proFromRight {
    float: right;
    // background: bisque;
    width: 450px;
    height: 100%;
  }
  .Box1Btn {
    position: absolute;
    bottom: 0;
    left: 100px;
  }
}
//募集周期
//基本信息
.InfoMation {
  width: 100%;
  height: 540px;
}
.MOV {
  position: absolute;
  right: 8px;
  top: 0;
  font-size: 12px;
}
</style>

<style>
.el-tabs {
  height: 80% !important;
}
.ql-editor {
  height: 500px !important;
}
.media-quill img {
  height: 80px;
}
</style>